Smart Sensor Bridge


Smart Sensor Bridge

Turn your Phone into a Virtual IoT Sensor

💡 Why I Created This App

As an Electronics & Communication Engineering student, I noticed a common problem many beginners face when building robots or IoT projects:

"Hardware sensors like MPU6050 Accelerometers are often expensive, require complex wiring, and need difficult calibration code. Many students give up just because of these hardware hurdles."

The Solution? Use what you already have!

Every modern smartphone has powerful, high-precision IMU sensors built-in. I created Smart Sensor Bridge to unlock these sensors and stream their data directly to your microcontroller via Bluetooth.

  • Save Money: No need to buy external Gyroscopes or Accelerometers.
  • Save Time: No messy wiring on breadboards.
  • Easy to Use: Perfect for controlling RC cars, robotic arms, and drones.

📖 How It Works

The app reads your phone's movement (X, Y, Z axes) and converts it into a simple text string. This string is sent over Bluetooth to your robot.

1. The "Reset Position" Feature
Calibration is key. When you mount your phone on a robot, it might be tilted. Clicking RESET POSITION sets the current angle as "Zero." This ensures your robot stays still until you actually move the phone.
2. Data Output Format
Example Output: X12.50Y-3.20Z0.00\n
  • X... = Forward/Backward Tilt (Pitch)
  • Y... = Left/Right Tilt (Roll)
  • Z... = Rotation (Yaw)

🔌 Hardware Connections

Option A: ESP32

The BEST option. ESP32 has built-in Bluetooth.

  • Wiring: None! Just power it via USB.
  • Pairing: Connect to "ESP32_Bridge".

Option B: Arduino + HC-05

Using external Bluetooth module.

  • VCC → 5V
  • GND → GND
  • TX → Arduino Pin 2
  • RX → Arduino Pin 3

💻 Code 1: For ESP32

Upload this code if you are using an ESP32 board.

#include "BluetoothSerial.h"

BluetoothSerial SerialBT;
String receivedData = "";

void setup() {
  Serial.begin(115200);
  SerialBT.begin("ESP32_Bridge"); 
  Serial.println("Bluetooth Started! Ready to pair.");
}

void loop() {
  if (SerialBT.available()) {
    char c = SerialBT.read();
    
    if (c == '\n') {
      parseData(receivedData);
      receivedData = ""; 
    } else {
      receivedData += c;
    }
  }
}

void parseData(String data) {
  int xInd = data.indexOf("X");
  int yInd = data.indexOf("Y");

  if (xInd > -1 && yInd > -1) {
    String xStr = data.substring(xInd + 1, yInd);
    String yStr = data.substring(yInd + 1);
    
    float xVal = xStr.toFloat();
    float yVal = yStr.toFloat();

    Serial.print("Tilt X: "); Serial.print(xVal);
    Serial.print(" | Tilt Y: "); Serial.println(yVal);
  }
}

💻 Code 2: For Arduino (Uno/Nano)

Upload this if you are using an Arduino with an HC-05 module.

#include <SoftwareSerial.h>

// RX on Pin 2, TX on Pin 3
SoftwareSerial SerialBT(2, 3); 
String receivedData = "";

void setup() {
  Serial.begin(9600);   
  SerialBT.begin(9600); // Default HC-05 Speed
  Serial.println("HC-05 Ready!");
}

void loop() {
  if (SerialBT.available()) {
    char c = SerialBT.read();
    
    if (c == '\n') {
      parseData(receivedData);
      receivedData = "";
    } else {
      receivedData += c;
    }
  }
}

void parseData(String data) {
  int xInd = data.indexOf("X");
  int yInd = data.indexOf("Y");

  if (xInd > -1 && yInd > -1) {
    String xStr = data.substring(xInd + 1, yInd);
    String yStr = data.substring(yInd + 1);
    
    float xVal = xStr.toFloat();
    float yVal = yStr.toFloat();

    Serial.print("X: "); Serial.print(xVal);
    Serial.print(" Y: "); Serial.println(yVal);
  }
}

👨‍💻 Developed by B. Jeyaram Reddy

Electronics & Communication Engineer

Comments

Popular posts from this blog

Temperature Sensor Fan Circuit

DIY Microphone Amplifier Circuit using BC547 Transistor

Face Drive Bot (App Guide)